<template>
  <!-- 个人简历的首页 -->
  <div class="page page-lyd">
    <div class="top-title-section">
      <h1>Caculate列表页面</h1>
    </div>
    <!-- 列表 -->
    <div class="long-list-section">
      <div v-for="(item, index) in divs" :key="index" class="user" @click="clickItemAction(item, index)">
        {{ item }}
      </div>
    </div>
  </div>
</template>

<script>
  import { bubbleSort, selectionSort, insertionSort, mergeSort, quickSort, heapSort} from './CaculateList.js'
  export default {
    data() {
      return {
        chooseIndex: -1,
        // 创建一个包含一千个空对象的数组
        divs: ['冒泡排序','选择排序','插入排序','归并排序','快速排序','堆排序']
      };
    },
    computed: {
  
    },
    created() {},
    mounted() {},
    methods: {
      clickItemAction(item, index) {
        console.log('点击了第',item, index);
        let arr = [3, 38, 47, 15, 36, 26, 2, 4, 19, 50, 48];
        let finalArr = [];

        if(item === '冒泡排序') {
          finalArr = bubbleSort(arr)
        } else if(item === '选择排序') {
          finalArr = selectionSort(arr)
        } else if(item === '插入排序') {
          finalArr = insertionSort(arr)
        } else if(item === '归并排序') {
          finalArr = mergeSort(arr)
        } else if(item === '快速排序') {
          finalArr = quickSort(arr)
        } else if(item === '堆排序') {
          finalArr = heapSort(arr)
        }
        
 

        console.log('finalArr', finalArr);
        

      }
    }
  };
</script>

<style lang="less" scoped src="./style.less"></style>
